package org.scribe.model;

import java.io.OutputStream;
import java.util.logging.Logger;

/**
 * Parameter object that groups OAuth config values
 * 
 * @author Pablo Fernandez
 */
public class OAuthConfig {
	private Logger logger = Logger.getLogger(OAuthConfig.class.getName());
	private final String apiKey;
	private final String apiSecret;
	private final String callback;
	private final SignatureType signatureType;
	private final String scope;

	public OAuthConfig(String key, String secret) {
		this(key, secret, null, null, null, null);
	}

	public OAuthConfig(String key, String secret, String callback, SignatureType type, String scope, OutputStream stream) {
		this.apiKey = key;
		this.apiSecret = secret;
		this.callback = callback;
		this.signatureType = type;
		this.scope = scope;
	}

	public String getApiKey() {
		return apiKey;
	}

	public String getApiSecret() {
		return apiSecret;
	}

	public String getCallback() {
		return callback;
	}

	public SignatureType getSignatureType() {
		return signatureType;
	}

	public String getScope() {
		return scope;
	}

	public boolean hasScope() {
		return scope != null;
	}

	public void log(String message) {
		if (logger != null) {
			message = message + "\n";
			try {
				logger.info(new String(message.getBytes("UTF8")));
			} catch (Exception e) {
				throw new RuntimeException("there were problems while writting to the debug stream", e);
			}
		}
	}
}
